#include "CMenuItem.h"

CMenuItem::CMenuItem()
{
	VelX(0);
	VelY(0);
	m_travelingVec.fX = 0;
	m_travelingVec.fY = -1;
}

CMenuItem::~CMenuItem()
{

}

void CMenuItem::Init(
	CBitmapFont* bfFont, float fPosX, float fPosY, 
	char* szName, IGameState* gsTarget, float fSize)
{
	PosX(fPosX);
	PosY(fPosY);
	TarPosX(0);
	TarPosY(0);
	Name(szName);
	Font(bfFont);
	Size(fSize);
	VelX(0);
	VelY(0);
	m_gsTarget = gsTarget;
}

void CMenuItem::Update(float fElapsedTime)
{
	m_travelingVec.fX = 0;
	m_travelingVec.fY = -1;
	if(TarPosX() != PosX() || TarPosY() != PosY())
	{
		m_travelingVec.fX = TarPosX() - PosX();
		m_travelingVec.fY = TarPosY() - PosY();
		VelX(m_travelingVec.fX);
		VelY(m_travelingVec.fY);
	}
	else
	{
		VelX(0);
		VelY(0);
	}
	PosX(PosX()+(VelX()*fElapsedTime));
	PosY(PosY()+(VelY()*fElapsedTime));
}

void CMenuItem::Render(bool bSelected)
{
	if(!bSelected)
		m_bfFont->DrawBitmapText(const_cast<char*>(m_szName.c_str()), (int)PosX(), (int)PosY(), Size());
	else
		m_bfFont->DrawBitmapText(const_cast<char*>(m_szName.c_str()), (int)PosX(), (int)PosY(), Size(), D3DCOLOR_ARGB(255,255,0,0));
}

void CMenuItem::GoTo(float fTarPosX, float fTarPosY)
{
	m_fTarPosX = fTarPosX;
	m_fTarPosY = fTarPosY;
}